﻿using System;
using EzDesk.DesktopClient.Command;
using EzDesk.DesktopClient.Event;
using EzDesk.DesktopClient.ViewContract;
using EzDesk.DesktopClient.MVVMEnhance;

namespace EzDesk.DesktopClient.ViewModel
{
    public class ContentTabViewModel : ViewModelWithSingleContainer<IContentTabView>, IContentTabViewModel
    {
        public ContentTabViewModel()
        {
            _isContentDisplayed = true;
            ToggleTodoViewExpansionEvent.Instance.Subscribe(
                p => IsContentDisplayed = !p, EventAggregation.ThreadOption.UIThread);

            FilterFeedByIsMarkCommand = new DelegateCommand<object>(this.OnFilterFeedByIsMark);
        }

        private void OnFilterFeedByIsMark(object starSelected)
        {
            ToggleFilterFeedIsMarkEvent.Instance.Publish((bool)starSelected);
        }

        public DelegateCommand<object > FilterFeedByIsMarkCommand { get; private set; }

        private FeedViewModel _feedViewModel;

        public FeedViewModel FeedViewModel
        {
            get { return _feedViewModel = _feedViewModel ?? new FeedViewModel(); }
            set
            {
                _feedViewModel = value;
                RaisePropertyChanged("FeedViewModel");
            }
        }

        #region IsContentDisplayed Property
        private bool _isContentDisplayed;

        public bool IsContentDisplayed
        {
            get { return _isContentDisplayed; }
            private set
            {
                if(_isContentDisplayed != value)
                {
                    _isContentDisplayed = value;
                    RaisePropertyChanged("IsContentDisplayed");
                }
            }
        }
        #endregion

    }
}
